<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>壹码当先 - 修改密码</title>

    <script type="text/javascript" src="/pages/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            /**
             * 查看用户信息
             */
            $.post("/user/detail", {}, function (result) {
                if (result.status === 1) {
                    var data = result.data;
                    $("#header").html('<img id="header" src="' + data.header + '">');
                    $("#nickName").html(data.nickName);
                    $("#studentId").html(data.studentId);
                } else {
                    alert("用户未登录");
                    window.location.href = "/pages/index.html";
                }
            });
        })

        /**
         * 保存用户密码
         */
        function save() {
            var url = "/user/edit";
            var password = $("#password").val(), oldPassword = $("#oldPassword").val(),
                    repassword = $("#repassword").val();
            if (checkout(password,repassword,oldPassword)) {
                $.post(url, {
                    password:password,
                    oldPassword:oldPassword
                }, function (result) {
                    if(result.status===1){
                        alert("修改密码成功");
                        window.location.href="/pages/ymdx/users/information.html"
                    }
                    else{
                        alert("修改失败");
                    }
                })
            }else{
                alert("密码为空或密码不一致");
            }
        }

        /**
         * 参数校验
         */
        function checkout(password,repassword,oldpassword) {
            if(password.length==0||repassword.length==0||oldpassword.length==0){
                return false;
            }
            if(repassword == password){
                return true;
            }
            return false;
        }
    </script>
    <link href="/pages/css/kefu.css" rel="stylesheet">
    <script type="text/javascript" src="/pages/js/jquery001.js"></script>
    <!-- Chosen CSS -->
    <link href="/pages/css/login-register.css" rel="stylesheet">
    <!-- Pretty Photo CSS -->
    <link href="/pages/css/prettyPhoto.css" rel="stylesheet">
    <!-- Chosen CSS -->
    <link href="/pages/css/chosen.min.css" rel="stylesheet">
    <!-- Chosen CSS -->
    <link href="/pages/css/dashboard.css" rel="stylesheet">
    <!-- Custom Main StyleSheet CSS -->
    <link href="/pages/style.css" rel="stylesheet">
    <!-- Color CSS -->
    <link href="/pages/css/color.css" rel="stylesheet">
    <link href="/pages/css/color-2.css" rel="stylesheet">
    <!-- Responsive CSS -->
    <link href="/pages/css/responsive.css" rel="stylesheet">

</head>

<body onload="IFrameResize()">

<script type="text/javascript">
    function IFrameResize() {
        //alert(this.document.body.scrollHeight); //弹出当前页面的高度
        var obj = parent.document.getElementById("iframe1");  //取得父页面IFrame对象
        //alert(obj.height); //弹出父页面中IFrame中设置的高度
        obj.height = this.document.body.scrollHeight;  //调整父页面中IFrame的高度为此页面的高度
    }
</script>

<!--Sub Banner Wrap Start -->
<div class="gt_sub_banner_bg default_width">
    <div class="container">
        <div class="gt_sub_banner_hdg  default_width">
            <h2>修改密码</h2>
            <h6>壹码当先&nbsp;·&nbsp;让更多的孩子爱上编程</h6>
        </div>
    </div>
</div>
<!--Sub Banner Wrap End -->
<!--Breadcrumb Wrap End -->
<div class="gt_breadcrumb_bg default_width">
    <div class="container">
        <div class="gt_breadcrumb_wrap default_width">
            <ul>
                <li><a href="/pages/index.html">首页</a></li>
                <li><a href="#">修改密码</a></li>
            </ul>
        </div>
    </div>
</div>
<!--Breadcrumb Wrap End -->

<!--Main Content Wrap Start-->
<div class="gt_content_wrap">
    <!--Classes Wrap Start-->
    <section class="gt_courses_bg">
        <div class="container">

            <!-- Dashboard Side Bar Wrap Start -->
            <div class="col-md-4">
                <div class="gt-user-sidebar">
                    <div class="gt_d_author_wrap">
                        <div class="gt_d_author_pic">
                            <figure id="header">
                                <!--用户头像-->
                            </figure>
                        </div>
                        <div class="gt_d_author_pic_des">
                            <h5 id="nickName"></h5>
                            <span class="gt_hdg_span"></span>
                            <p>学员号</p>
                            <label id="studentId"></label>
                        </div>
                    </div>
                    <div class="gt-usser-account-list">
                        <ul>
                            <li><a href="information.html"><i class="icon-book gt-color"></i>个人信息</a></li>
                            <li><a href="myworks.html"><i class="icon-clock-1 gt-color"></i>我的作品</a></li>
                            <li><a href="editpwd.html"><i class="icon-three gt-color"></i>修改密码</a></li>
                        </ul>
                        <a href="#" class="gt-logout"><i class="icon-arrows-2 gt-color"></i>退出登录</a>
                    </div>
                </div>
            </div>
            <!-- Dashboard Side Bar Wrap End -->


            <!--Classes List Wrap Start-->
            <div class="col-md-8">
                <div class="gt_d_classes_wrap default_width mb20">
                    <h4 class="gt_d_title">修改密码</h4>
                    <div class="gt_d_profile_setting default_width">
                        <div class="row">
                            <div class="col-md-6" style="width: 100%;">
                                <div class="gt_privacy_field default_width mb20">
                                    <input id="oldPassword" class="c_ph" type="text" placeholder="原密码">
                                </div>
                            </div>
                            <div class="col-md-6" style="width: 100%;">
                                <div class="gt_privacy_field default_width mb20">
                                    <input id="password" class="c_ph" type="text" placeholder="新密码">
                                </div>
                            </div>
                            <div class="col-md-6" style="width: 100%;">
                                <div class="gt_privacy_field default_width mb20">
                                    <input id="repassword" class="c_ph" type="text" placeholder="再确认一遍新密码">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="gt_d_scl_setting default_width">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="gt_privacy_field default_width">
                                    <input onclick="save()" type="submit" value="保存">
                                </div>
                            </div>
                        </div>
                    </div>


                </div>
            </div>
            <!--Classes List Wrap End-->
        </div>
    </section>
    <!--Classes Wrap End-->
</div>
<!--Main Content Wrap End-->


<!--Jquery Library-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<!--Bootstrap core JavaScript-->
<script src="http://www.jq22.com/jquery/bootstrap-3.3.4.js"></script>
<!--Chosen JavaScript-->
<script src="/pages/js/chosen.jquery.min.js"></script>
<!--Custom JavaScript-->
<script src="/pages/js/custom.js"></script>

</body>
</html>
